package com.demo.controller;

import com.demo.pojo.User;
import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/{id}")
    public User getUser(@PathVariable("id")Integer id) {
        return userService.getUser(id);
    }
    @GetMapping
    public List<User> getAll(){
        return this.userService.getAll();
    }
    @DeleteMapping
    public Integer deleteUser(@RequestParam("id")Integer id){
        return this.userService.deleteUser(id);
    }
}
